from typing import final
import requests
from lxml import etree
from requests.api import head

url = 'https://movie.douban.com/subject/1292052/comments?status=P'
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.82'
}
response = requests.get(url,headers=headers)
# print(response.text)
html = etree.HTML(response.text)
comment_list = html.xpath('//span[@class="short"]/text()')

name_list = html.xpath('//*[@id="comments"]/div/div[2]/h3/span[2]/a/text()')

time_list = html.xpath('//*[@id="comments"]/div/div[2]/h3/span[2]/span[3]/@title')

# print("提取到的个数：", len(comment_list))
# for comment in comment_list:
#     print(comment)
#     print('\n')

# print("提取到的个数：", len(name_list))
# for name in name_list:
#     print(name.text)
#     print('\n')

# print("提取到的个数：", len(time_list))
# for time in time_list:
#     print(time)
#     print('\n')



final_list = list(zip(time_list, name_list,comment_list))
for i in final_list:
    print(i)
